#include <iostream>
#include <vector>
#include<algorithm>

using namespace std;

int main()
{
    int t = 0;
    cin >> t;
    while (t--)
    {
        long long n = 0;
        cin >> n;
        vector<int> arr(n);
        long long sum = 0;
        for (int i = 0; i < n; ++i)
        {
            cin >> arr[i];
            sum += arr[i];
        }
        sort(arr.begin(), arr.end());
        if (arr[n - 1] < ++arr[1])
            swap(arr[n - 1], arr[1]);
        cout << sum - arr[n - 1] - arr[0] + 1 << endl;
    }
    return 0;
}